package com.ljkj.common.db.util;

import java.util.ArrayList;
import java.util.List;

public class Setting {

	private List<String> pojoNames = null;
	private List<String> propertyNames = null;
	private List<Object> values = null;
	private List<String> likePropertyNames = null;
	private List<Object> likeValues = null;
	private List<String> betweenPropertyNames = null;
	private List<List<Object>> betweenValues = null;
	private List<String> orderByPropertyNames = null;
	private List<Object> orderByValues = null;

	public List<String> getPojoNames() {
		return pojoNames;
	}

	public void setPojoNames(List<String> pojoNames) {
		this.pojoNames = pojoNames;
	}

	public List<String> getPropertyNames() {
		return propertyNames;
	}

	public void setPropertyNames(List<String> propertyNames) {
		this.propertyNames = propertyNames;
	}

	public List<Object> getValues() {
		return values;
	}

	public void setValues(List<Object> values) {
		this.values = values;
	}

	public List<String> getLikePropertyNames() {
		return likePropertyNames;
	}

	public void setLikePropertyNames(List<String> likePropertyNames) {
		this.likePropertyNames = likePropertyNames;
	}

	public List<Object> getLikeValues() {
		return likeValues;
	}

	public void setLikeValues(List<Object> likeValues) {
		this.likeValues = likeValues;
	}

	public List<String> getBetweenPropertyNames() {
		return betweenPropertyNames;
	}

	public void setBetweenPropertyNames(List<String> betweenPropertyNames) {
		this.betweenPropertyNames = betweenPropertyNames;
	}

	public List<List<Object>> getBetweenValues() {
		return betweenValues;
	}

	public void setBetweenValues(List<List<Object>> betweenValues) {
		this.betweenValues = betweenValues;
	}

	public List<String> getOrderByPropertyNames() {
		return orderByPropertyNames;
	}

	public void setOrderByPropertyNames(List<String> orderByPropertyNames) {
		this.orderByPropertyNames = orderByPropertyNames;
	}

	public List<Object> getOrderByValues() {
		return orderByValues;
	}

	public void setOrderByValues(List<Object> orderByValues) {
		this.orderByValues = orderByValues;
	}

	@SuppressWarnings("rawtypes")
	public void setPOJOs(List<Class> pojos) {
		if (pojos == null) {
			throw new NullPointerException("parameter can not null!");
		}
		for (Class c : pojos) {
			this.pojoNames = new ArrayList<String>();
			this.pojoNames.add(c.getName());
		}
	}

	@SuppressWarnings("rawtypes")
	public void appendPOJO(Class c) {
		if (c == null) {
			throw new NullPointerException("parameter can not null!");
		}
		if (this.pojoNames == null) {
			this.pojoNames = new ArrayList<String>();
		}
		this.pojoNames.add(c.getName());
	}

	public void appendWhere(String propertyName, Object value) {
		if (propertyName == null) {
			throw new NullPointerException("parameter can not null!");
		}
		if (value == null) {
			throw new NullPointerException("parameter can not null!");
		}
		if (this.propertyNames == null) {
			this.propertyNames = new ArrayList<String>();
		}
		this.propertyNames.add(propertyName);
		if (this.values == null) {
			this.values = new ArrayList<Object>();
		}
		this.values.add(value);

	}

	public void appendLike(String likePropertyName, Object likeValue) {
		if (likePropertyName == null) {
			throw new NullPointerException("parameter can not null!");
		}
		if (likeValue == null) {
			throw new NullPointerException("parameter can not null!");
		}
		if (this.likePropertyNames == null) {
			this.likePropertyNames = new ArrayList<String>();
		}
		this.likePropertyNames.add(likePropertyName);
		if (this.likeValues == null) {
			this.likeValues = new ArrayList<Object>();
		}
		this.likeValues.add(likeValue);
	}

	public void appendBetween(String betweenPropertyName, List<Object> betweenValue) {
		if (betweenPropertyName == null) {
			throw new NullPointerException("parameter can not null!");
		}
		if (betweenValue == null) {
			throw new NullPointerException("parameter can not null!");
		}
		if (betweenValue.size() != 2) {
			throw new NullPointerException("second parameter size must 2!");
		}
		if (this.betweenPropertyNames == null) {
			this.betweenPropertyNames = new ArrayList<String>();
		}
		this.betweenPropertyNames.add(betweenPropertyName);
		if (this.betweenValues == null) {
			this.betweenValues = new ArrayList<List<Object>>();
		}
		this.betweenValues.add(betweenValue);
	}

	public void appendOrder(String orderByPropertyName, Object orderByValue) {
		if (orderByPropertyNames == null) {
			throw new NullPointerException("parameter can not null!");
		}
		if (orderByValues == null) {
			throw new NullPointerException("parameter can not null!");
		}
		if (this.orderByPropertyNames == null) {
			this.orderByPropertyNames = new ArrayList<String>();
		}
		this.orderByPropertyNames.add(orderByPropertyName);
		if (this.orderByValues == null) {
			this.orderByValues = new ArrayList<Object>();
		}
		this.orderByValues.add(orderByValue);
	}

}
